<?php namespace App\Model;

//use Illuminate\Database\Eloquent\Model;

class InfoExtRelate extends BaseModel {

//    public $timestamps = false;
    //
    public static function getExtRelatesByInfoId($infoId=0)
    {
        $extRelatesInfo = array();
        if(empty($infoId) || !is_numeric($infoId) || $infoId < 0){
            return $extRelatesInfo;
        }
        $extRelatesTemp = self::select(array('field_id','field_value'))
            ->where('info_id' , '=', $infoId)->get();
        foreach($extRelatesTemp as $extRelate){
            $extRelatesInfo[$extRelate->field_id] = $extRelate->field_value;
        }
        return $extRelatesInfo;
    }

    public static function addExtRelates($extRelatesData)
    {
        if(empty($extRelatesData)){
            return false;
        }
        return self::insert($extRelatesData);
    }
    public static function deleteExtRelates($infoId)
    {
        if(empty($infoId) || !is_numeric($infoId)){
            return false;
        }
//        return self::where('info_id',$infoId)->update(array('status'=>1));
        return self::where('info_id',$infoId)->delete();
    }
}
